package com.adingxiong.cft.design.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Meal
 * @Description TODO
 * @Author xiongchao
 * @Date 2021/1/7 16:44
 **/
public class Meal {

    private List<Item> items = new ArrayList<>();

    public void addItem(Item item){
        items.add(item);
    }

    public float getCost(){
        float cost = 0f;
        for (Item e : items) {
            cost += e.price();
        }
        return cost;
    }

    public void showItem(){
        for (Item item : items) {
            System.out.print("\t item: " + item.name());
            System.out.print( "\t, Packing:" + item.packing().pick());
            System.out.println("\t Price:" + item.price());
        }
    }
}
